var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, o) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var o in t)
              Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
          })(t, o);
      };
      return function (t, o) {
        function a() {
          this.constructor = t;
        }
        if ("function" != typeof o && null !== o)
          throw new TypeError(
            "Class extends value " + String(o) + " is not a constructor or null"
          );
        e(t, o),
          (t.prototype =
            null === o
              ? Object.create(o)
              : ((a.prototype = o.prototype), new a()));
      };
    })(),
  SetNewRole = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.requestCreateNewRoleFn = {
          caller: t,
          code: 390,
          method: function (e) {
            if (0 == e.code) {
              var o = [
                { url: "res/atlas/comp.atlas", type: Laya.Loader.ATLAS },
                { url: "res/atlas/common.atlas", type: Laya.Loader.ATLAS },
                {
                  url: "res/atlas/comp/commonpic.atlas",
                  type: Laya.Loader.ATLAS,
                },
                { url: "res/atlas/comp/happy.atlas", type: Laya.Loader.ATLAS },
                { url: "res/atlas/emoji.atlas", type: Laya.Loader.ATLAS },
                { url: "res/btn_womanRole.png", type: Laya.Loader.IMAGE },
                { url: "res/atlas/btn_womanRole.png", type: Laya.Loader.IMAGE },
                {
                  url: "res/atlas/comp/createRole/btn_womanRole.png",
                  type: Laya.Loader.IMAGE,
                },
              ];
              Laya.loader.load(
                o,
                null,
                Laya.Handler.create(
                  t,
                  function (o) {
                    if ((AXProgressBarView.onLoadedRecourse(o), 1 == o)) {
                      t.removeSelf();
                      var a = e.data,
                        r = new GameMainView(a);
                      Laya.stage.addChild(r),
                        r.reset(),
                        (Global.roleFirst = "roleFirst");
                    }
                  },
                  null,
                  !1
                )
              );
            } else ToastView.toastView(e.msg);
          },
        }),
        (t.tab_chooseNewRole.selectedIndex = 0),
        (t.set_nickname_lbl.visible = !1),
        (t.tab_chooseNewRole.selectHandler = new Laya.Handler(
          t,
          t.onNewRoleSelect
        )),
        WebSocketService.addListener(t.requestCreateNewRoleFn),
        (t.roleRadioGroup.selectHandler = new Laya.Handler(
          t,
          t.onRadioGroupSelect
        )),
        t.btn_setNewRoleDone.on(Laya.Event.CLICK, t, t.OnloadGame),
        t.btn_back.on(Laya.Event.CLICK, t, t.OnbackPre),
        t
      );
    }
    return (
      __extends(t, e),
      (t.openSetNewRole = function () {
        return (
          null == this.setNewRoleVC && (this.setNewRoleVC = new t()),
          (this.setNewRoleVC._clickTime = 0),
          (this.setNewRoleVC.roleRadioGroup.selectedIndex = 0),
          this.setNewRoleVC.onNewRoleSelect(0),
          this.setNewRoleVC
        );
      }),
      (t.prototype.onNewRoleSelect = function (e) {
        var t = 0;
        (t = 1 == this.roleRadioGroup.selectedIndex ? 4 : 1),
          0 == e
            ? (this.lbl_roleDescr.text = "武士：单体攻击，秒杀对手")
            : 1 == e
            ? (this.lbl_roleDescr.text = "文人：控制技能，限制对手")
            : 2 == e && (this.lbl_roleDescr.text = "异师：团体攻击，爆炸输出");
        this.getChildByName("roleImage").skin =
          "comp/hreoImg/ws" +
          (t + this.tab_chooseNewRole.selectedIndex) +
          "_m.png";
      }),
      (t.prototype.onRadioGroupSelect = function (e) {
        var t = this.getChildByName("roleImage"),
          o = 0;
        1 == e ? (o = 4) : 0 == e && (o = 1),
          (t.skin =
            "comp/hreoImg/ws" +
            (o + this.tab_chooseNewRole.selectedIndex) +
            "_m.png");
      }),
      (t.prototype.OnbackPre = function () {
        this.removeSelf();
      }),
      (t.prototype.OnloadGame = function () {
        if (!(Laya.Browser.now() - this._clickTime <= 1500)) {
          this._clickTime = Laya.Browser.now();
          this.set_nickname_lbl.text;
          var e = this.tab_chooseNewRole.selectedIndex + 1,
            t = 1 - this.roleRadioGroup.selectedIndex;
          WebSocketService.send({
            c: 390,
            d: { sex: t, roleType: e, headIndex: 2 },
          });
        }
      }),
      t
    );
  })(ui.SetNewRoleUI);
